<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>添加栏目 - Powered By BETOU.NET</title>
<meta name="author" content="BETOU.NET Team" />
<meta name="copyright" content="BETOU.NET" />
<link href="${base}/res/betou/css/common.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="${base}/res/common/js/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="${base}/thirdparty/datepicker/WdatePicker.js"></script>
<script type="text/javascript" src="${base}/res/betou/js/jquery.tools.js" ></script>
<script type="text/javascript" src="${base}/res/betou/js/jquery.validate.js"></script>
<script type="text/javascript" src="${base}/res/common/js/common.js"></script>
<script type="text/javascript" src="${base}/res/betou/js/input.js"></script>

<script type="text/javascript" src="${base}/thirdparty/editor/xheditor-1.2.1.min.js"></script>
<script type="text/javascript" src="${base}/thirdparty/editor/xheditor_lang/zh-cn.js"></script>
<script type="text/javascript" src="${base}/thirdparty/editor/editor.js"></script>

<script type="text/javascript">
function appendModelTpl(modelId,tpl){
	var hasContain = false;
	$("input[name=modelIds]").each(function() {
		if($(this).val()==modelId) {
			hasContain = true;
		}
	});
	if(hasContain) {
		return;
	}
	var html="<input name='modelIds' value='"+modelId+"' type='hidden'/>";
	html+="<input name='tpls' value='"+tpl+"' type='hidden'/>";
	$("#modelsContainer").append(html);
}


function appendModelOnOk( ){
	$("input[id^='model']:checked").each(function(){
		var modelCheckId=$(this).attr("id").split("model")[1];
		var selectId="selectModel_"+modelCheckId;
		appendModelTpl($(this).val(),$("#"+selectId).val());
	});
}
$(function() {
	var $browserButton = $("input.browserButton");
	var $inputForm = $("#inputForm");
	
	$browserButton.browserDialog({
				title:"<@s.m 'channel.selectModelTpl'/>", 
				ok:"确定",
				cancel:"取消",
				onOk:appendModelOnOk,
				callback: function(){$("#modelTplDialog").html("")}, // 清空原来的内容
				content:$("#modelTplDialog").html()
		}		
	);
	
	$("#inputForm table.tabContent").each( function(i,e){
		var len = $(this).find( "tr" ).length;
		if( len == 0 ){
			$("#tab li").eq(i).hide();
			$(this).hide();
		}
	});
	// 表单验证
	$inputForm.validate({
		rules: {
			<#list itemList as item>
			<#if item.field=="name">
			name:{required:true,minlength:2,maxlength:30}
			<#elseif item.field=="path">
			,path:{required:true,maxlength:30,pattern:/^[0-9a-z_A-Z]+$/}
			<#elseif item.field=="priority">
			,priority:{required:true,digits: true}
			<#elseif item.field=="finalStep">
			,finalStep:{digits:true}
			</#if>
			</#list>
		},
		message:{}
	});
	
});

</script>
</head>
<body>
	<div class="path">
		<a href="../right.do">首页</a> &raquo; <a href="v_list.do"><@s.m "channel.function"/></a> &raquo; <@s.m "global.add"/>
	</div>
	<form id="inputForm" action="o_save.do" method="post" >
		<ul id="tab" class="tab">
			<li><input type="button" value="基本设置" /></li>
			<li><input type="button" value="SEO设置" /></li>
			<li><input type="button" value="权限设置" /></li>
			<li><input type="button" value="栏目设置" /></li>
			<li><input type="button" value="内容设置" /></li>
			<li><input type="button" value="自定义字段" /></li>
		</ul>
		<table class="input tabContent">
			<tr>
				<th><@s.m "channel.parent"/>:</th>
				<td><#if parent??>${parent.name}<#else><@s.m "channel.top"/></#if></td>
			</tr>
			<tr>
				<th><@s.m "channel.model"/>:</th>
				<td>${model.name}</td>
			</tr>
			<#list itemList as item>
				<#if item.field=="name">
				<tr>
					<th><span class="requiredField">*</span>${item.label}:</th>
					<td><input type="text"  title="${item.help!}" name="${item.field}"  vld="{required:true}" class="text" value="${item.defValue!}" maxlength="100" /></td>
				</tr>
				<#elseif item.field=="path">
				<tr>
					<th><span class="requiredField">*</span>${item.label}:</th>
					<td><input type="text"  title="${item.help!}" name="${item.field}" class="text" value="${item.defValue!}" maxlength="30" /></td>
				</tr>
				<#elseif item.field=="priority">
				<tr>
					<th><span class="requiredField">*</span>${item.label}:</th>
					<td><input type="text"  title="${item.help!}" name="${item.field}" class="text" value="${item.defValue!10}" maxlength="8" /></td>
				</tr>
				<#elseif item.field=="display">
				<tr>
					<th><span class="requiredField">*</span>${item.label}:</th>
					<td>
						<span class="fieldSet">
							<label>
								<input type="radio"  class="radio" name="${item.field}" value="true" checked/><@s.m "global.true"/>
							</label>
							<label>
								<input type="radio"  class="radio" name="${item.field}" value="false"/><@s.m "global.false"/>
							</label>
							<label><input type="checkbox" onclick="$('#blank').val(this.checked);"/><@s.m "channel.blank"/></label>
							<input type="hidden" id="blank" name="blank" value="false"/>
						</span>
					</td>
				</tr>
				</#if>
			</#list>
		</table>
		<table class="input tabContent">
			<#list itemList as item>
				<#if item.field == "title">
					<tr>
						<th>${item.label}:</th>
						<td><input type="text"  title="${item.help!}"  name="${item.field}" class="text" value="${item.defValue!}" maxlength="255" /></td>
					</tr>
				<#elseif item.field=="keywords">
					<tr>
						<th>${item.label}:</th>
						<td><input type="text" title="${item.help!}"  name="${item.field}" class="text" value="${item.defValue!}" maxlength="255" /></td>
					</tr>
				<#elseif item.field=="description">
					<tr>
						<th>${item.label}:</th>
						<td>
							<textarea class="text" maxlength="255" title="${item.help!}"  name="description">${item.defValue!}</textarea>
						</td>
					</tr>
					
				</#if>
			</#list>
		</table>
		<table class="input tabContent">
		<#list itemList as item>
			<#if item.field=="finalStep">
				<#assign h><#if item.help??>${item.help}<#else><@s.m "channel."+item.field+".help"/></#if></#assign>
				<tr>
					<th>${item.label}:</th>
					<td><input type="text"  name="${item.field}"  class="text" value="${item.defValue!}" maxlength="5" title="${h}"/></td>
				</tr>
			<#elseif item.field=="afterCheck">
				<tr>
					<th>${item.label}:</th>
					<td>
						<select name="${item.field}" class="valid">
							<option value=""><@s.m "global.default"/></option>
							<option value="1"><@s.m "cmsSite.afterCheck.1"/></option>
							<option value="2"><@s.m "cmsSite.afterCheck.2"/></option>
							<option value="3"><@s.m "cmsSite.afterCheck.3"/></option>
						</select>
					</td>
				</tr>
			<#elseif item.field=="commentControl">
				<tr>
					<th>${item.label}:</th>
					<td>
						<span class="fieldSet">
							<label>
								<input type="radio"  class="radio" name="${item.field}" value="0" checked/><@s.m "channel.commentControl.0"/>
							</label>
							<label>
								<input type="radio"  class="radio" name="${item.field}" value="1"/><@s.m "channel.commentControl.1"/>
							</label>
							<label>
								<input type="radio"  class="radio" name="${item.field}" value="2"/><@s.m "channel.commentControl.2"/>
							</label>
						</span>
					</td>
				</tr>
			<#elseif item.field=="allowUpdown">
				<tr>
					<th>${item.label}:</th>
					<td>
						<span class="fieldSet">
							<label>
								<input type="radio"  class="radio" name="${item.field}" value="true" checked/><@s.m "global.allow"/>
							</label>
							<label>
								<input type="radio"  class="radio" name="${item.field}" value="false"/><@s.m "global.notAllow"/>
							</label>
						</span>
					</td>
				</tr>
			<#elseif item.field=="viewGroupIds">
				<tr>
					<th>${item.label}:</th>
					<td>
						<span class="fieldSet">
							<#list viewGroups as g>
							<label>
								<input type="checkbox"  name="${item.field}" value="${g.id}"/>${g.name!}
							</label>
							</#list>
						</span>
					</td>
				</tr>
			<#elseif item.field=="contriGroupIds">
				<tr>
					<th>${item.label}:</th>
					<td>
						<span class="fieldSet">
							<#list contriGroups as g>
							<label>
								<input type="checkbox"  name="${item.field}" value="${g.id}"/>${g.name!}
							</label>
							</#list>
						</span>
					</td>
				</tr>
				
				<#elseif item.field=="userIds" && users?size gt 0>
				<tr>
					<th>${item.label}:</th>
					<td>
						<span class="fieldSet">
							<#list users as g>
							<label>
								<input type="checkbox"  name="${item.field}" value="${g.id}"/>${g.username!}
							</label>
							</#list>
						</span>
					</td>
				</tr>
			</#if>
		</#list>
		</table>
		<table class="input tabContent">
		<#list itemList as item>
		<#if item.field=="tplChannel">
			<tr>
				<th>${item.label}:</th>
				<td>
					<span class="fieldSet">
						<select name="${item.field}" class="valid">
						<option value=""><@s.m "global.default"/></option>
						<#list channelTplList as g>
							<option value="${g}">${g}</option>
						</#list>
						</select>
					</span>
				</td>
			</tr>
		<#elseif item.field=="tplContent">
			<tr>
				<th>${item.label}:</th>
				<td>
					<input type="button"  class="button  browserButton" id="openModelTplDialog" value="${item.label!}" name="${item.field}" title="<@s.m 'channel.modelTpl.help'/>"/>
				</td>
			</tr>
		<#elseif item.field=="channelStatic">
			<tr>
				<th>${item.label}:</th>
				<td>
					<span class="fieldSet">
						<label><input type="checkbox" onclick="$('#staticChannel').val(this.checked)"/><@s.m "channel.staticOn"/><input type="hidden" id="staticChannel" name="staticChannel" value="false"/>	</label>
						<input type="text" name="channelRule" class="text"/>
						<label><input type="checkbox" onclick="$('#accessByDir').val(this.checked)"/><@s.m "channel.accessByDir"/><input type="hidden" id="accessByDir" name="accessByDir" value="false"/></label>
						<label><input type="checkbox" onclick="$('#listChild').val(this.checked)"/><@s.m "channel.listChild"/><input type="hidden" id="listChild" name="listChild" value="false"/></label>
						<@s.m "channel.pageSize"/>:
						<select name="pageSize">
								<option value="5" <#if channel.pageSize?? && channel.pageSize == 5>selected="selected"</#if> >5条</option>
								<option value="10" <#if channel.pageSize?? && channel.pageSize == 10>selected="selected"</#if>>10条</option>
								<option value="15" <#if channel.pageSize?? && channel.pageSize == 15>selected="selected"</#if>>15条</option>
								<option value="20" <#if channel.pageSize?? && channel.pageSize == 20>selected="selected"</#if>>20条</option>
							</select>
					</span>
					
				</td>
			</tr>
		<#elseif item.field=="contentStatic">
			<tr>
					<th>${item.label}:</th>
					<td>
						<span class="fieldSet">
							<label><input type="checkbox" onclick="$('#staticContent').val(this.checked)"/><@s.m "channel.staticOn"/><input type="hidden" id="staticContent" name="staticContent" value="false"/></label>
							<input type="text" name="contentRule" class="text"/>
						</span>
					</td>
			</tr>
		<#elseif item.field=="link">
		<#assign h><#if item.help??>${item.help}<#else><@s.m "content."+item.field+".help"/></#if></#assign>
		<tr>
			<th>${item.label}:</th>
			<td>
				<input type="text"  name="${item.field}" class="text" value="${item.defValue!}" maxlength="255" title="${h}"/>
			</td>
		</tr>
		</#if>
		</#list>
		</table>
		<table class="input tabContent">
			<#list itemList as item>
				<#if item.field=="txt">
				<tr>
					<th>${item.label}:</th>
					<td>
						<textarea class="text" name="${item.field}" id="${item.field}" class="xheditor">${item.defValue!}</textarea>
						<script type="text/javascript">
						$('#${item.field}').xheditor({
							width:800,height:200,linkTag:true,showBlocktag:false,internalScript:false,inlineScript:false,internalStyle:false,
							inlineStyle:false,disableContextmenu: true,html5Upload:false,upImgUrl:"/xheditor/upload.jspx",upImgExt:"jpg,jpeg,gif,png"
							});
						</script>
					</td>
				</tr>
				<#elseif item.field=="txt1">
				<tr>
					<th>${item.label}:</th>
					<td>
						<textarea class="text" name="${item.field}" id="${item.field}" class="xheditor">${item.defValue!}</textarea>
						<script type="text/javascript">
						$('#${item.field}').xheditor({
							width:800,height:200,linkTag:true,showBlocktag:false,internalScript:false,inlineScript:false,internalStyle:false,
							inlineStyle:false,disableContextmenu: true,html5Upload:false,upImgUrl:"/xheditor/upload.jspx",upImgExt:"jpg,jpeg,gif,png"
							});
						</script>
					</td>
				</tr>
				<#elseif item.field=="txt2">
				<tr>
					<th>${item.label}:</th>
					<td>
						<textarea class="text" name="${item.field}" id="${item.field}" class="xheditor">${item.defValue!}</textarea>
						<script type="text/javascript">
						$('#${item.field}').xheditor({
							width:800,height:200,linkTag:true,showBlocktag:false,internalScript:false,inlineScript:false,internalStyle:false,
							inlineStyle:false,disableContextmenu: true,html5Upload:false,upImgUrl:"/xheditor/upload.jspx",upImgExt:"jpg,jpeg,gif,png"
							});
						</script>
					</td>
				</tr>
				<#elseif item.field=="txt3">
				<tr>
					<th>${item.label}:</th>
					<td>
						<textarea class="text" name="${item.field}" id="${item.field}" class="xheditor">${item.defValue!}</textarea>
						<script type="text/javascript">
						$('#${item.field}').xheditor({
							width:800,height:200,linkTag:true,showBlocktag:false,internalScript:false,inlineScript:false,internalStyle:false,
							inlineStyle:false,disableContextmenu: true,html5Upload:false,upImgUrl:"/xheditor/upload.jspx",upImgExt:"jpg,jpeg,gif,png"
							});
						</script>
					</td>
				</tr>
				</#if>
			</#list>
		</table>
		<table class="input tabContent">
			<#list itemList as item>
			<#if item.custom>
				<@p.selfDefineWidget name="attr_${item.field}" value=item.defValue list="${item.optValue!}" help=item.help  label=item.label type="${item.dataType}"/>
			</#if>
			</#list>
		</table>
		<table class="input not">
			<tr>
				<th>&nbsp;</th>
				<td>
					<input type="hidden" name="root" value="${root!}"/>
					<input type="hidden" name="modelId" value="${model.id}"/>
					<input type="submit" class="button" value="确&nbsp;&nbsp;定" />
					<input type="button" class="button" value="返&nbsp;&nbsp;回" onclick="location.href='v_list.do'" />
					<div id="modelsContainer"></div>
				</td>
			</tr>
		</table>
	</form>
<div id="modelTplDialog"  style="display:none">
<table class="input">
<#list models as m>
<tr>
	<th><input  type="checkbox" value="${m.id}" id="model${m.id}" />${m.name}</th>
	<td>
		<select name="tpls" id="selectModel_${m.id}">
		<option value=""><@s.m "global.default"/></option>
		<#list modelTplMap[m.id?string] as tpl>
		<option value="${tpl}">${tpl}</option>
		</#list>
		</select>
	</td>
</tr>
</#list>
</table>
</div>
	
</body>
</html>